
#include "factory.h"
#include <stdio.h>

class A
{
  public:
   int a;
};

class B : public A
{
  public:
   int b;
};


bool factory_test_signlton_empty()
{
  ClassFactory factory;
  int *pint = factory.getSingelton<int>("int");
  return ((unsigned long)pint == (unsigned long)null) ? true : false;
}

bool factory_test_signlton_not_empty()
{
  ClassFactory factory;
  factory.Register<int>("int");
  int *pint0 = factory.getSingelton<int>("int");
  int *pint1 = factory.getSingelton<int>("int");

  return ((unsigned long)pint0 == (unsigned long)pint1) ? true : false;
}


bool factory_test_not_signlton_not_empty()
{
  ClassFactory factory;
  factory.Register<int>("int");
  int *pint0 = factory.getObject<int>("int");
  int *pint1 = factory.getObject<int>("int");
  return ((unsigned long)pint0 != (unsigned long)pint1) ? true : false;
}

bool factory_test_inheritance()
{
  ClassFactory factory;
  factory.Register<B>("clasB");
  B *cb = factory.getSingelton<B>("clasB");
  cb->a = 5;
  A *ca = factory.getSingelton<A>("clasB");
  return (ca->a == cb->a) ? true : false;
}

bool factory_test_clear()
{
  ClassFactory factory;
  factory.Register<B>("clasB");
  B *cb = factory.getSingelton<B>("clasB");
  factory.deRegitrateObject<A>("clasB");
  return (factory.findObject<B>("clasB") == null) ? true : false;
}
